﻿using ModelLayer;
using ModelLayer.DTO;
using ModelLayer.Graph;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Threading.Tasks;

namespace WcfServiceLayer.ServiceContracts
{
    [ServiceContract]
    interface IClientService
    {

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/RouteReservation/{id}", ResponseFormat = WebMessageFormat.Json)]
        RouteReservation GetById(string id);

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/AllReservations", ResponseFormat = WebMessageFormat.Json)]
        IList<RouteReservation> GetUserReservations(string sessionToken); //token that is assigned to user session this way he doesn't have to rewrite password

        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/Graph",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        Task<StationNetworkGraph> GetGraph(double[] startCoords, double[] endCoords, BatteryType desiredType, string sessionToken);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/AllBatteryTypes", ResponseFormat = WebMessageFormat.Json)]
        IList<BatteryType> GetAllBatteryTypes();


        [OperationContract]
        [WebInvoke(Method = "POST", 
            UriTemplate = "/LogIn",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        Stream LogInUser(string username, string password);


        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/SignUp", ResponseFormat = WebMessageFormat.Json)]
        bool SignUp(UserAccount accountToCreate);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/ConfirmEmail/{sessionToken}")]
        void ConfirmAccount(string sessionToken);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/GetAllAccounts", ResponseFormat = WebMessageFormat.Json)]
        Stream GetAllAccounts();    //since WCF is not able to handle inheritance I had to do it in a raw manner

        //Just a test, delete later
        [OperationContract]
        [WebInvoke(Method = "POST", UriTemplate = "/CheckBatteryType", ResponseFormat = WebMessageFormat.Json)]
        BatteryType CheckBatteryType(BatteryType type);

        [OperationContract]
        [WebInvoke(Method = "GET", UriTemplate = "/sth", ResponseFormat = WebMessageFormat.Json)]
        PointReservationDTO sth();

        [OperationContract]
        [WebInvoke(Method = "POST",
            UriTemplate = "/ReserveRoute",
            ResponseFormat = WebMessageFormat.Json,
            RequestFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        bool TryToReserveRoute(IList<PointReservationDTO> pointsToReserve, BatteryType desiredType, string sessionToken);

        #region Useless option functions that I have to create to make WCF happy

        [OperationContract]
        [WebInvoke(Method = "OPTIONS", UriTemplate = "/Graph")]
        void GetOptionsGraph();

        [OperationContract]
        [WebInvoke(Method = "OPTIONS", UriTemplate = "/SignUp")]
        void GetOptionsSignUp();

        [OperationContract]
        [WebInvoke(Method = "OPTIONS", UriTemplate = "/LogIn")]
        void GetOptionsLogIn();

        [OperationContract]
        [WebInvoke(Method = "OPTIONS", UriTemplate = "/ReserveRoute")]
        void GetOptionsTryToReserveRoute();

        [OperationContract]
        [WebInvoke(Method = "OPTIONS", UriTemplate = "/sth")]
        void GetOptionssth();

        #endregion


    }

    
}
